---
title: DynamoDB Client
description: AWS DynamoDB client usage
keywords:
  - electrodb
  - docs
  - concepts
  - dynamodb
  - logger
  - logging
  - event
  - listener
layout: ../../../layouts/MainLayout.astro
---

ElectroDB supports both the [v2](https://www.npmjs.com/package/aws-sdk) and [v3](https://www.npmjs.com/package/@aws-sdk/client-dynamodb) aws clients. The client can be supplied creating a new Entity or Service, or added to an Entity/Service instance via the `setClient()` method.

_On the instantiation of an `Entity`:_

```typescript
import { Entity } from "electrodb";
import { DocumentClient } from "aws-sdk/clients/dynamodb";
const table = "my_table_name";
const client = new DocumentClient({
  region: "us-east-1",
});

const task = new Entity(
  {
    // your model
  },
  {
    client, // <----- client
    table,
  },
);
```

_On the instantiation of an `Service`:_

```typescript
import { Entity } from "electrodb";
import { DocumentClient } from "aws-sdk/clients/dynamodb";
const table = "my_table_name";
const client = new DocumentClient({
  region: "us-east-1",
});

const task = new Entity({
  // your model
});

const user = new Entity({
  // your model
});

const service = new Service(
  { task, user },
  {
    client, // <----- client
    table,
  },
);
```

_Via the `setClient` method:_

```typescript
import { Entity } from "electrodb";
import { DocumentClient } from "aws-sdk/clients/dynamodb";
const table = "my_table_name";
const client = new DocumentClient({
  region: "us-east-1",
});

const task = new Entity({
  // your model
});

task.setClient(client);
```

## V2 Client

The [v2](https://www.npmjs.com/package/aws-sdk) sdk will work out of the box with the DynamoDB DocumentClient.

_Example:_

```typescript
import { DocumentClient } from "aws-sdk/clients/dynamodb";
const client = new DocumentClient({
  region: "us-east-1",
});
```

## V3 Client

The [v3](https://www.npmjs.com/package/@aws-sdk/client-dynamodb) client will work out of the box with the DynamoDBClient.

```typescript
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
const client = new DynamoDBClient({
  region: "us-east-1",
});
```
